<?php

namespace App\Http\Middleware;

use Carbon\Carbon;
use Closure;
use Illuminate\Support\Facades\Redis;

class LastLogin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if(env('APP_ENV')=='production'){
            Redis::set('lastLogin'.$request['u'],Carbon::now(),'EX',86400*7);
        }
        return $next($request);
    }
}
